package com.tbit.api;

import com.tbit.manager.api.RefundServiceApi;
import com.tbit.manager.api.dto.RefundReturnDTO;
import com.tbit.manager.api.dto.UserMoneyRefundDTO;
import com.tbit.uqbike.object.value.LoginInfo;
import com.tbit.common.entity.view.Result;
import com.tbit.uqbike.service.business.RefundService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * 退款接口
 *
 */
@RestController
@Slf4j
public class RefundServiceApiImpl implements RefundServiceApi {

    @Autowired
    private RefundService refundService;
    @Override
    public com.tbit.common.entity.view.Result<RefundReturnDTO> userMoneyRefund(UserMoneyRefundDTO userMoneyRefundDTO) {
        LoginInfo loginInfo = new LoginInfo();
        loginInfo.setAccountUserId(userMoneyRefundDTO.getLoginUserAccountUserId());
        loginInfo.setName(userMoneyRefundDTO.getLoginUserName());
        loginInfo.setPhone(userMoneyRefundDTO.getLoginUserPhone());
        loginInfo.setLoginUserPlatform(userMoneyRefundDTO.getLoginUserPlatform());
        com.tbit.uqbike.object.pojo.dto.UserMoneyRefundDTO userMoneyRefundDTOManager =
                new com.tbit.uqbike.object.pojo.dto.UserMoneyRefundDTO(userMoneyRefundDTO.getUserId(),
                        userMoneyRefundDTO.getRefundMoney().longValue(), userMoneyRefundDTO.getPsw());
        Result<com.tbit.uqbike.object.pojo.dto.RefundReturnDTO> result =
                refundService.userMoneyRefund(loginInfo, userMoneyRefundDTOManager);
        com.tbit.common.entity.view.Result<RefundReturnDTO> commonResult = new com.tbit.common.entity.view.Result<>();
        BeanUtils.copyProperties(result, commonResult);
        return commonResult;
    }

    @Override
    public com.tbit.common.entity.view.Result<RefundReturnDTO> queryRefundResult(String refundBusinessNO) {
        Result<com.tbit.uqbike.object.pojo.dto.RefundReturnDTO> refundReturnDTOResult = refundService.queryRefundResult(refundBusinessNO);
        com.tbit.common.entity.view.Result<RefundReturnDTO> commonResult = new com.tbit.common.entity.view.Result<>();
        BeanUtils.copyProperties(refundReturnDTOResult, commonResult);
        return commonResult;
    }
}
